<?php
if($__userid > 0){	// 已经登录
	go('./index.php?frm=user');
}
if(!empty($_POST['formAction'])){
	$errmsg = array();
	if(empty($_POST['username'])){
		$errmsg[] = '未输入用户名';
	}
	if(empty($_POST['password'])){
		$errmsg[] = '未输入密码';
	}elseif(strlen($_POST['password']) < 6){
		$errmsg[] = '密码格式不正确';
	}
	if(empty($_POST['checkcode'])){
		$errmsg[] = '未输入验证码';
	}elseif(authnum_check() == false){
		$errmsg[] = '验证码不正确';
	}
	
	if(!empty($errmsg)){
		$errmsg = implode($__br, $errmsg);
		ajax_msg('warning', $errmsg, $callback = 'callback_login', $synjs = '', $ttl = 2000);
	}
	
	$_POST['remember'] = empty($_POST['remember']) ? 0 : 2592000;
	$r = $__oUser->login($_POST);
	if(isset($r['userinfo']['userid']) && $r['userinfo']['userid'] > 0){ // 登录成功
		// $js = $__oUser->set_session_cookie($_POST['remember']);
		// if($js != false){
			ajax_msg('succ', '', 'callback_login', $r['userinfo']['synjs']);
		// }
	}
	ajax_msg($r['result'], $r['rmsg'], 'callback_login');
}

// 保存登录前地址
$__url = REF_URL;
set_session('url', $__url);

/*******************************************************************************
 * 页面信息　& 当前位置
 *******************************************************************************/
url_here('登录', './index.php?mdl=user&do=login');
?>